#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
  void moveZeroes(vector<int> &nums) {
    int lastnozero = -1;
    int pointer = 0;
    while (pointer < nums.size()) {
      if (nums[pointer] != 0) {
        nums[++lastnozero] = nums[pointer];
      }
      ++pointer;
    }
    while (lastnozero < nums.size() - 1) {
	    nums[++lastnozero] = 0;
    }
  }
};

int main() {
	vector<int> a = {0,1,0,3,12};
	Solution s;
	s.moveZeroes(a);
	for(auto p = a.begin(); p != a.end(); ++p)
	{
		cout<<*p<<" ";
	}
	cout<<endl;
}
